﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using BusinessFacade;
using Entities;
using Comm;

namespace MedicareNoteManagerWeb
{
    public partial class login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }


        public static string UserID = "";
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {

            if (Text_LoginName.Text.Length > 0)
            {
                int time_out = int.Parse(ConfigurationManager.AppSettings["CookiesTimeOut"] + "");
                DateTime endDay = DateTime.Now.AddMinutes(time_out);
                sys_user_Model model = new sys_user_Model();
                Busi_sys_user userlogin = new Busi_sys_user();
                string UserName = Text_LoginName.Text.Trim();
                string Password = Text_PassWord.Text.Trim();
                //作为密码方式加密    
                string pwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(Password, "MD5");
                model = userlogin.Login(UserName, pwd);
                if (model == null)
                {
                    MessageBox.Show(this.Page, "Not OK");
                }
                else
                {
                    UserID = model.UserID.ToString();
                    //MessageBox.Show(this.Page, "OK");
                    Session["UserModel"] = model;
                    Response.Redirect("Web/MainForm.aspx");
                    
                }
            }
        }
    }
}